package com.example.photography.adapter.store;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.photography.R;
import com.example.photography.bean.StoreHomeBean;
import com.youth.banner.adapter.BannerAdapter;
import com.youth.banner.util.BannerUtils;

import java.util.List;

public class ActAdapter extends BannerAdapter<StoreHomeBean.ResultBean.ActInfoBean, ActAdapter.ActHolder> {
    public ActAdapter(List<StoreHomeBean.ResultBean.ActInfoBean> actInfoBeans) {
        super(actInfoBeans);
    }

    @Override
    public ActHolder onCreateHolder(ViewGroup parent, int viewType) {
        return new ActHolder(BannerUtils.getView(parent, R.layout.item_act));
    }
    /**
        * 相当于getView中的绑定数据模块
        * @param holder
        * @param position
     */
    @Override
    public void onBindView(ActHolder holder, StoreHomeBean.ResultBean.ActInfoBean data, int position, int size) {
        holder.message.setText(data.getAdvertisement());
        holder.seller.setText(data.getSeller());
        holder.time.setText(data.getTime());
    }

    class ActHolder extends RecyclerView.ViewHolder {
        public TextView message;
        public TextView seller;
        public TextView time;


        public ActHolder(@NonNull View view) {
            super(view);
            message = view.findViewById(R.id.message);
            seller = view.findViewById(R.id.seller);
            time = view.findViewById(R.id.time);
        }
    }

}
